home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-02-10 | 2.1 KB | 102 lines | [TEXT/CWIE] |
- // CCMArea version 1.3.2
- // 2-10-98
- // by David Catmull
-
- /* History:
-
- 9-19-97 First version
-
- 10-21-97 Removed AdjustCursorSelf
-
- 12-22-97 ClickSelf checks CMClick's return value
-
- 2-10-98 Only calls CMClick when active & enabled
- */
-
- #include "UCMArea.h"
- #include "CCMEditField.h"
- #include "CCMWindow.h"
- #include <Appearance.h>
-
- void
- CCMEditField::FinishCreateSelf()
- {
- // Make sure mSuperCMArea is set.
-
- if (!mSuperCMArea) {
- LView *superView;
-
- UCMArea::FindSuperCMArea(this,mSuperCMArea,superView);
- }
- }
-
- void
- CCMEditField::ClickSelf(const SMouseDownEvent &inMouseDown)
- {
- // True from CMClick means go ahead and handle the event
-
- if (IsEnabled() && IsActive())
- if (CMClick(inMouseDown) == cm_Nothing)
- LEditField::ClickSelf(inMouseDown);
- }
-
- void
- CCMEditField::GetSelectionDesc(AEDesc &outSelDesc)
- {
- short start,end;
- OSErr err;
-
- // Return either the current selection, or the entire text.
-
- start = (**mTextEditH).selStart;
- end = (**mTextEditH).selEnd;
-
- if (end > start)
- err = AECreateDesc(typeChar,*(**mTextEditH).hText+start,end-start,&outSelDesc);
- else
- err = AECreateDesc(typeChar,*(**mTextEditH).hText,(**mTextEditH).teLength,&outSelDesc);
- }
-
-
- void
- CCMEditField::BuildMenuSelf(MenuHandle inMenu)
- {
- // You can just blindly call AddCommandToMenu for everything, since it
- // checks to see if the commands are enabled. To override this, pass
- // true for inOverrideDisable (it defaults to false).
-
- UCMArea::AddCommandToMenu(inMenu,cmd_Cut);
- UCMArea::AddCommandToMenu(inMenu,cmd_Copy);
- UCMArea::AddCommandToMenu(inMenu,cmd_Paste);
- UCMArea::AddCommandToMenu(inMenu,cmd_SelectAll);
-
- /* This is an example of how you would add a submenu
-
- ::AppendMenu(inMenu,"\pOther");
-
- mSubMenu = ::NewMenu(255,"\p");
-
- AddCommandToMenu(mSubMenu,cmd_About);
- AddCommandToMenu(mSubMenu,cmd_Undo);
-
- ::InsertMenu(mSubMenu,hierMenu);
- ::SetMenuItemHierarchicalID(inMenu,::CountMenuItems(inMenu),255);
- */
- }
-
- void
- CCMEditField::CleanUpMenus()
- {
- /* If you had a submenu:
- ::DeleteMenu(255);
- ::DisposeMenu(mSubMenu);
- */
- }
-
- void
- CCMEditField::PreClick(const SMouseDownEvent &inMouseDown)
- {
- #pragma unused (inMouseDown)
- LCommander::SwitchTarget(this);
- }
-